# _*_ coding:utf-8 _*_
from __future__ import unicode_literals

from datetime import datetime

from django.contrib.auth.models import AbstractUser
# Create your models here.
from django.db import models


class UserProfile(AbstractUser):
    nick_name = models.CharField(max_length=20, verbose_name=u'昵称' )
    birthday = models.DateField(verbose_name=u'生日', null=True, blank=True)
    address = models.TextField(max_length=50, verbose_name=u'地址')
    gender = models.CharField(verbose_name='性别 ', max_length=10, choices=(("male", u"男"), ("female", u"女")),
                              default='male')
    mobile = models.CharField(max_length=11, null=True, blank=True, verbose_name=u"手机号码")
    image = models.ImageField(verbose_name='头像', upload_to="image/%y/%m", default=u"image/default.png", max_length=100)
    # Trading信息
    brokerID = models.CharField(max_length=8, null=True, blank=True, verbose_name=u"brokerID")
    userID = models.CharField(max_length=8, null=True, blank=True, verbose_name=u"userID")
    password_trader = models.CharField(max_length=20, null=True, blank=True, verbose_name=u"password_trader")

    class Meta:
        verbose_name = "用户信息"
        verbose_name_plural = verbose_name

    def __unicode__(self):
        return self.username


class EmailVerifyRecord(models.Model):
    code = models.CharField(max_length=20, verbose_name=u"验证码")
    email = models.EmailField(max_length=50, verbose_name=u"邮箱")
    send_type = models.CharField(verbose_name='验证码类型', choices=(("register", u"注册"), ("forget", u"忘记密码")), max_length=10)
    send_time = models.DateTimeField(default=datetime.now, verbose_name=u"发送时间")

    class Meta:
        verbose_name = u'邮箱验证码'
        verbose_name_plural = verbose_name


# 用户消息表
class UserMessage(models.Model):
    user = models.IntegerField(default=0, verbose_name=u"接收用户")
    message = models.CharField(max_length=500, verbose_name=u"消息内容")

    # 是否已读: 布尔类型 BooleanField False未读,True表示已读
    has_read = models.BooleanField(default=False, verbose_name=u"是否已读")
    add_time = models.DateTimeField(default=datetime.now, verbose_name=u"添加时间")

    class Meta:
        verbose_name = u"用户消息"
        verbose_name_plural = verbose_name

    def __unicode__(self):
        return '用户({0})接收了{1} '.format(self.user, self.message)


class UserPay(models.Model):
    pass

    class Meta:
        verbose_name = '用户费用管理'
        verbose_name_plural = verbose_name


class DataBackup(models.Model):
    pass

    class Meta:
        verbose_name = '数据备份'
        verbose_name_plural = verbose_name


